<template>
  <div class="tab">
    <router-link v-for="tab of tabs" :key="tab.path" :to="tab.path" class="tab-item">
      <span class="tab-link">{{tab.name}}</span>
    </router-link>
  </div>
</template>

<script>
  import { defineComponent } from 'vue'

  export default defineComponent({
    name: 'tab',
    setup() {
      const tabs = [
        {
          name: '推荐',
          path: '/recommend'
        },
        {
          name: '歌手',
          path: '/singer'
        },
        {
          name: '排行',
          path: '/rank'
        },
        {
          name: '搜索',
          path: '/search'
        }
      ]
      return {
        tabs
      }
    }
  })
</script>

<style lang="scss" scoped>
  .tab {
    display: flex;
    height: 44px;
    line-height: 44px;
    font-size: $font-size-medium;
    .tab-item {
      flex: 1;
      text-align: center;
      .tab-link {
        padding-bottom: 5px;
        color: $color-text-l;
      }
      &.router-link-active {
        .tab-link {
          color: $color-theme;
          border-bottom: 2px solid $color-theme;
        }
      }
    }
  }
</style>
